package com.flash.BusinessData.mapper;

import com.flash.BusinessData.entity.DealData;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface DealDataMapper {
    @Select("select * from (\n" +
            "select dbs.*,rownum rn from\n" +
            "(SELECT * FROM dealData d JOIN \n" +
            "(SELECT * FROM cash) sa ON d.cashId = sa.cashId JOIN \n" +
            "(SELECT * FROM security) se ON d.securityId  = se.securityId JOIN \n" +
            "(SELECT * FROM broker) b ON b.brokerId = d.brokerId where 1=1 ${strWhere}) dbs)\n" +
            "WHERE rn between #{page} and #{limit} ")
    List<DealData> selectDealDataMap(Map map);

    @Select("select count(*) from dealData")
    int selectCountDealData();

    @Insert("insert into dealData values (#{dealId},#{securityId},#{seatId},#{cashId},#{fundId},#{brokerId},#{dealTime},#{dealNumber},#{dealPrice},#{endTime},#{endMoney},#{dealMoney},#{commissionFees},#{transferFee},#{stampDuty},#{control},#{handle},#{securityInterest},#{dealWay},#{dealState})")
    int insertDealData(DealData dealData);

    @Delete("delete from dealData where dealId=#{dealId}")
    int deleteDealData(String dealId);


    @Update("update dealData set securityId = #{securityId},seatId = #{seatId},cashId = #{cashId},fundId=#{fundId},brokerId=#{brokerId},dealTime=#{dealTime},dealNumber=#{dealNumber},dealPrice=#{dealPrice},endTime=#{endTime} ,endMoney=#{endMoney},dealMoney=#{dealMoney},commissionFees=#{commissionFees},transferFee=#{transferFee} ,stampDuty=#{stampDuty} ,control=#{control} ,handle=#{handle}  ,securityInterest=#{securityInterest} ,dealWay=#{dealWay},dealState=#{dealState} where dealId = #{dealId}")
    int updateDeaData(DealData dealData);


}
